package com.ibm.cps.spark.streaming.adapter;

import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.IRichBolt;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.tuple.Tuple;

import java.util.List;
import java.util.Map;

/**
 * Created by telekinesis on 4/28/15.
 */
public class TestPrintBolt implements IRichBolt {
    private OutputCollector collector;

    @Override
    public void prepare(Map map, TopologyContext topologyContext, OutputCollector outputCollector) {
        this.collector = outputCollector;
    }

    @Override
    public void execute(Tuple tuple) {
        List<Object> values = tuple.getValues();
        System.out.println("received " + values);
        int items = values.size();
        System.out.println(items + " items");
        for (int i = 0; i < items; i++) {
            System.out.println(i + " : " + values.get(i).toString());
        }
    }

    @Override
    public void cleanup() {

    }

    @Override
    public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {

    }

    @Override
    public Map<String, Object> getComponentConfiguration() {
        return null;
    }
}
